package com.chanyachting.emall.action.companyproduct;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Rentyacht;
import com.chanyachting.emall.form.RentyachtForm;
import com.chanyachting.emall.service.CompanyproductService;
import com.chanyachting.emall.service.RentyachtService;
import com.chanyachting.emall.serviceImpl.CompanyproductServiceImpl;
import com.chanyachting.emall.serviceImpl.RentyachtServiceImpl;
import com.chanyachting.emall.util.DateUtil;

public class UpdateRentyachtAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		RentyachtForm syform=(RentyachtForm)form;
		
		Rentyacht sy= null;
		try {
			RentyachtService rentyachtService=new RentyachtServiceImpl();
			
			Rentyacht tempRent = rentyachtService.QueryOneRentyacht(syform.getId().toString());
			sy=new Rentyacht();
			
			BeanUtils.copyProperties(sy, syform);
			
			sy.setUpdateDate(DateUtil.getDate()); 
			sy.setCreateDate(tempRent.getCreateDate());
			sy.setTitle(sy.getName());
			sy.setStatus("00");
			
			CompanyproductService cpservice=new CompanyproductServiceImpl();
			
			cpservice.updateCompanyproduct(sy);  
			
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		
		return mapping.findForward("updateRentyacht");
		
	}
	
	

}
